<?php
namespace app\beautiful\model\mall;
use app\common\model\CommonModel;

class GoodsModel extends CommonModel{
    protected  $name = 'beautiful_goods';
    protected  $pk   = 'goods_id';
    protected $type=[
        'rotation'=>'array',
        'goods_details'=>'array'
    ];

    public function sku()
    {
        return $this->hasMany(GoodsSkuModel::class,'goods_id','goods_id');
    }
    public function findsku()
    {
        return $this->hasOne(GoodsSkuModel::class,'goods_id','goods_id');
    }

    public function getPreSaleTimeAttr($value,$data)
    {
        return $data['yu_days']>0 ? date("m月d日",strtotime("+".$data['yu_days']." day")) : '';
    }
}
